package com.dao.impl;

// Generated 15 f�vr. 2013 15:56:26 by Hibernate Tools 4.0.0

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.dao.TelephoneDao;
import com.model.Telephone;
import com.model.TelephoneId;

/**
 * Home object for domain model class Telephone.
 * @see com.model.Telephone
 * @author Hibernate Tools
 */
@Repository
public class TelephoneHome implements TelephoneDao{

	private static final Logger log = Logger.getLogger(TelephoneHome.class);

	@PersistenceContext
	private EntityManager entityManager;

	public void create(Telephone transientInstance) {
		log.debug("persisting Telephone instance");
		try {
			entityManager.persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void delete(Telephone persistentInstance) {
		log.debug("removing Telephone instance");
		try {
			entityManager.remove(persistentInstance);
			log.debug("remove successful");
		} catch (RuntimeException re) {
			log.error("remove failed", re);
			throw re;
		}
	}

	public Telephone update(Telephone detachedInstance) {
		log.debug("merging Telephone instance");
		try {
			Telephone result = entityManager.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Telephone findById(TelephoneId id) {
		log.debug("getting Telephone instance with id: " + id);
		try {
			Telephone instance = entityManager.find(Telephone.class, id);
			log.debug("get successful");
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}
